//
//  CaiPuNearbyViewController.m
//  KCZ_B段项目
//
//  Created by dllo on 15/11/9.
//  Copyright © 2015年 Sky. All rights reserved.
//

#import "CaiPuNearbyViewController.h"
#import <BaiduMapAPI_Base/BMKBaseComponent.h>
#import <BaiduMapAPI_Map/BMKMapComponent.h>
#import <BaiduMapAPI_Location/BMKLocationComponent.h>
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
@interface CaiPuNearbyViewController ()<BMKLocationServiceDelegate, BMKGeoCodeSearchDelegate>
@property(nonatomic, strong)BMKLocationService *locService;
@property(nonatomic, strong)BMKGeoCodeSearch *search;
@end

@implementation CaiPuNearbyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    _search = [[BMKGeoCodeSearch alloc]init];
    _locService = [[BMKLocationService alloc]init];
#pragma mark 开始定位
    [_locService startUserLocationService];
}
-(void)viewWillAppear:(BOOL)animated
{
    _locService.delegate = self;
   
    _search.delegate = self;
    
}
-(void)viewWillDisappear:(BOOL)animated
{
    _locService.delegate = nil;
    _search.delegate = nil;
}
#pragma mark 用户位置更新,调用方法
-(void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
{
    CGFloat lat = userLocation.location.coordinate.latitude;
    CGFloat lon = userLocation.location.coordinate.longitude;
    BMKOpenPoiNearbyOption *option = [[BMKOpenPoiNearbyOption alloc]init];
    option.appScheme = @"baidumapsdk://mapsdk.baidu.com";
    option.keyword = @"美食";
    option.location = CLLocationCoordinate2DMake(lat, lon);
    //周边距离半径
    option.radius = 1000;
    BMKOpenErrorCode code = [BMKOpenPoi openBaiduMapPoiNearbySearch:option];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
